import { defineConfig, loadEnv } from '@rsbuild/core';
import { pluginVue2 } from '@rsbuild/plugin-vue2';
import { pluginSass } from '@rsbuild/plugin-sass';
const { publicVars } = loadEnv({ prefixes: ["VUE_APP_"] });

export default defineConfig({
  html: {
    title: 'Example',
    meta: {
      charset: {
        charset: 'UTF-8',
      },
      viewport: 'width=device-width,initial-scale=1,maximum-scale=1,minimum-scale=1,viewport-fit=cover',
      description: 'a description of the page',
    },
  },
  performance: {
    chunkSplit: {
      strategy: 'split-by-experience'
    },
  },
  output: {
    assetPrefix: './',
    dataUriLimit: {
      image: 5000,
      media: 0,
    },
    polyfill: 'entry',
  },
  dev: {
    client: {
      protocol: 'ws',
      // 通常使用 `127.0.0.1`，可以避免跨域请求被浏览器拦截
      host: '127.0.0.1',
      port: 3000,
    },
    lazyCompilation: true,
  },
  plugins: [
    pluginVue2(),
    pluginSass()
  ],
  source: {
    define: publicVars,
    entry: {
      index: "./src/main.js"
    },
    alias: {
      '@': './src',
    },
  },
});
